/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Young Ran
 */
public class DB_Util {

    public static Connection getConnection() {
        Connection cn = null;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
            //String url = "jdbc:sqlserver://lab1_server:1433;databaseName=PrimePhysique";           
            //String username = "sa";
            //String password = "fat123456@";
            String url = "jdbc:sqlserver://localhost:1433;databaseName=PrimePhysique";
            String username = "sa";
            String password = "123456";
            cn = DriverManager.getConnection(url, username, password);

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        }
        return cn;
    }
}
